#include<bits/stdc++.h>
#define int long long
using namespace std;
const double eps=1e-5;
const int N=1e5+10;
int n,m,L,V,p[N];
vector<pair<int,int> >vv;
void scan(){
    vv.clear();
    int d,v,a;
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        cin>>d>>v>>a;
        if(a==0)
            if(v>V)
                vv.push_back(make_pair(d,L));
        if(a>0)
            if(sqrt(v*v*1.0+2*a*(L-d))>V)
                vv.push_back(make_pair(d+max((int)0,(int)ceil((V*V-v*v)/2.0/a+eps)),L));
        if(a<0)
            if(v>V)
                vv.push_back(make_pair(d,min(L,d+(int)floor((V*V-v*v)/2.0/a-eps))));
    }
    for(int i=1;i<=m;i++)
        cin>>p[i];
    return;
}
bool cmp(pair<int,int>x,pair<int,int>y){
    return x.second<y.second;
}
void work(){
    vector<pair<int,int> >vvv=vv;vv.clear();
    int cnt=0;
    for(int i=0,j=0;i<vvv.size();i++){
        while(j+1<=m&&p[j+1]<=vvv[i].second) j++;
        if(vvv[i].first<=p[j]) vv.push_back(vvv[i]);
    }
    for(int i=0,j=0;i<vv.size();i++){
        if(vv[i].first<=p[j]) continue;
        while(j+1<=m&&p[j+1]<=vv[i].second) j++;
        cnt++;
    }
    cout<<vv.size()<<' '<<m-cnt<<'\n';
    return;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        scan();
        sort(vv.begin(),vv.end(),cmp);
        work();
    }
    return 0;
}